package com.zhiyou100.loans.util;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Calendar;
import java.util.Date;

public class NetDate {
	public static Date getCurrentTime(){
		Date current=null;
		try {
			URL url = new URL("http://www.baidu.com");
			URLConnection uc=url.openConnection();
			long time=uc.getDate();
			current=new Date(time);
			
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return current;
	}
	
	public static int getDays(Date date){
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		cal.set(Calendar.DATE, 1);
		cal.roll(Calendar.DATE, -1);
		
		return cal.get(Calendar.DATE);
	}
}
